package com.xiaotu.spider.pipeline;

import com.xiaotu.common.model.TVProcessDataModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @author zhangxiao
 * @create 2021-01-22 10:53
 */
@Component("TVProcessDataPipeline")
public class TVProcessDataPipeline extends APipeline {

    @Override
    protected void doProcess(ResultItems resultItems, Task task) {
        TVProcessDataModel m = (TVProcessDataModel) resultItems.get(TVProcessDataModel.class.getName());
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.TV_ProcessData_YYYYMMDD);
        cacheHandler.hSet(key, m.getTvid() + "_" + m.getTvName() + "_" + m.getSiteName(), m);
        cacheHandler.setCacheTimeout(key);
    }

}
